#include "fuzzy_control.h"

#include "device.h"

const int fuzzy_logic[3][5] = 
{
  {-300, -200, -100, 0, 0},   //  e = -1
  {0, -100, 0, 100, 0},     //  e = 0
  {0, 0, 100, 200, 300},      //  e = 1
};

int fuzzy_velocity_difference(void)
{
  int e,ec,u;
  
  e = gray_front_error();
  ec = e - gray_back_error();
  
  u = fuzzy_logic[e+1][ec+2];     /* e,ec 和模糊控制表差了个固定的数  */
  
  return u;
}







